package top.kindaries.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import top.kindaries.mapper.JiraInfoMapper;
import top.kindaries.model.JiraInfo;
import top.kindaries.service.JiraInfoService;

import javax.annotation.Resource;
import java.util.List;

/**
 * Jira信息serviceImpl类
 *
 * @ClassName: JiraInfoServiceImpl
 * @Author: zhangs
 * @Date: Created in 2021-05-18 15:31
 * @Created by IntelliJ IDEA.
 */
@Service
public class JiraInfoServiceImpl implements JiraInfoService {

    @Resource
    private JiraInfoMapper jiraInfoMapper;

    @Override
    public boolean addJiraInfo(JiraInfo jiraInfo) {
        return jiraInfoMapper.insJiraInfo(jiraInfo) == 1;
    }

    @Override
    public boolean removeJiraInfo(String jiraId) {
        return jiraInfoMapper.delJiraInfoById(jiraId) == 1;
    }

    @Override
    public boolean editJiraInfo(JiraInfo jiraInfo) {
        return jiraInfoMapper.updJiraInfo(jiraInfo) == 1;
    }

    @Override
    public PageInfo<JiraInfo> getJiraInfo(JiraInfo jiraInfo) {
        //将参数传给这个方法就可以实现物理分页了，非常简单。
        PageHelper.startPage(jiraInfo.getPageNum(), jiraInfo.getPageSize(), jiraInfo.getOrderBy());
        List<JiraInfo> visitorList = jiraInfoMapper.getJiraInfoByKey(jiraInfo);
        return new PageInfo<>(visitorList);
    }

}
